package com.ming.yygh.hosp.controller;

import com.ming.yygh.common.result.Result;
import com.ming.yygh.hosp.service.ScheduleService;
import com.ming.yygh.model.hosp.Schedule;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author Light
 * @date 2021/12/13 9:40
 */
@Api(tags = "医院排班")
@RestController
@RequestMapping("admin/hosp/schedule")
//@CrossOrigin
public class ScheduleController {

    @Resource
    private ScheduleService scheduleService;

    // 根据医院编号和科室编号，查询排班规则数据
    @ApiOperation(value = "查询排班规则数据")
    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result<Map<String, Object>> getScheduleRule(@PathVariable(value = "page") Long page,
                                                       @PathVariable(value = "limit") Long limit,
                                                       @PathVariable(value = "hoscode") String hoscode,
                                                       @PathVariable(value = "depcode") String depcode) {
        Map<String, Object> map = scheduleService.getRuleSchedule(page, limit, hoscode, depcode);
        return Result.ok(map);
    }

    // 根据医院编号、科室编号和工作的日期，查询排班详细信息
    @ApiOperation(value = "查询排班详细信息")
    @GetMapping("getScheduleDetail/{hoscode}/{depcode}/{workDate}")
    public Result<List<Schedule>> getScheduleDetail(@PathVariable(value = "hoscode") String hoscode,
                                    @PathVariable(value = "depcode") String depcode,
                                    @PathVariable(value = "workDate") String workDate) {
        List<Schedule> scheduleList = scheduleService.getDetailSchedule(hoscode, depcode, workDate);
        return Result.ok(scheduleList);
    }

}
